package com.lzq.model.builder;

/**
 * @author : modify
 * @version : v1.0
 * @description :
 * @createTime : 2022/11/17 20:07
 * @updateUser : modify
 * @updateTime : 2022/11/17 20:07
 * @updateRemark :
 */
public class Phone {
    private String cpu;
    private String screen;
    private String memory;

    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", screen='" + screen + '\'' +
                ", memory='" + memory + '\'' +
                '}';
    }

    private Phone(PhoneBuilder phoneBuilder) {
        this.cpu = phoneBuilder.cpu;
        this.screen = phoneBuilder.screen;
        this.memory = phoneBuilder.memory;
    }

    public static final class PhoneBuilder {
        private String cpu;
        private String screen;
        private String memory;

        public PhoneBuilder cpu(String cpu) {
            this.cpu = cpu;
            return this;
        }

        public PhoneBuilder screen(String screen) {
            this.screen = screen;
            return this;
        }

        public PhoneBuilder memory(String memory) {
            this.memory = memory;
            return this;
        }

        public Phone builder() {
            return new Phone(this);
        }
    }
}

class PhoneTest {
    public static void main(String[] args) {
        Phone phone = new Phone.PhoneBuilder().cpu("天玑9100").memory("16G").screen("LCD").builder();
        System.out.println(phone.toString());
    }
}
